package com.yztc.thinkpad.mandemo.single;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.yztc.thinkpad.mandemo.R;
import com.yztc.thinkpad.mandemo.single.bean.CategoriesBean;


import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;
import utils.AdapterUtils;

/**
 * Created by meidou on 2016/10/6.
 */
public class SingleTypeAdapter extends AdapterUtils<CategoriesBean> {
    public SingleTypeAdapter(Context mcontext, List<CategoriesBean> totalList) {
        super(mcontext, totalList);
    }

    @Override
    public View getMyView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder;
        if (convertView == null) {
            convertView = mInflater.inflate(R.layout.item_grid_single, parent, false);
            viewHolder = new ViewHolder(convertView);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        Glide.with(mcontext).load(totalList.get(position).getCateimg()).into(viewHolder.mImageTypeSingle);
        viewHolder.mTitleTypeSingle.setText(totalList.get(position).getName());
        return convertView;
    }

    class ViewHolder {
        @Bind(R.id.image_type_single)
        ImageView mImageTypeSingle;
        @Bind(R.id.title_type_single)
        TextView mTitleTypeSingle;
        ViewHolder(View view){
            ButterKnife.bind(this,view);
        }
    }
}
